<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Ingreso Recursos</title>
    </h:head>
    <h:body>
        <h:form id="formLogin">
            <p:growl id="message" showDetail="true" life="3000"/>
            <h:outputLink id="loginLink" value="javascript:void(0)" onclick="PF('loginDlg').show()" title="Ingreso"> 
                <p:graphicImage style="width: 90px; height: 90px; position:absolute;left:50%;top:50%; margin:-75px 0 0 -135px;" value="/images/login.jpg" />
            </h:outputLink>
           
            <p:dialog id="dialog" header="Ingreso" widgetVar="loginDlg" resizable="false">
                 
                <h:panelGrid columns="3" cellpadding="5">
                    <p:outputLabel for="usuario" value="Usuario:"/>
                    <p:inputText id="usuario" required="true" autocomplete="false" value="#{controladorLogin.usuario}"
                                 requiredMessage="Ingrese el campo usuario"
                                 label="usuario" maxlength="10">
                                 <f:validator validatorId="com.validator.digits" />
                    </p:inputText>
                    <h:messages for="usuario"/>
                    <p:outputLabel for="contrasena" value="Contraseña:" />
                    <p:password id="contrasena" required="true" label="contrasena" maxlength="10" value="#{controladorLogin.password}"
                                requiredMessage="Ingrese el campo contraseña">
                        <f:validator validatorId="com.validator.lettersydigits"/>
                    </p:password>
                    <h:message for="contrasena"/>
                    
                    
                    <h:panelGroup/>
                    <f:facet name="footer">
                        
                        <p:commandButton id="loginButton" value="login"
                                         update="message"  action="#{controladorLogin.login}"
                                         oncomplete="handleLoginRequest(xhr, status, args)"/>
                    </f:facet>
                </h:panelGrid>
            </p:dialog>    
        </h:form>
        <script type="text/javascript">
            function handleLoginRequest(xhr, status, args) {
                if (args.validationFailed || !args.loggedIn) {
                    PF('loginDlg').jq.effect("shake", {times: 5}, 100);
                }
                else {
                    PF('loginDlg').hide();
                    $('#loginLink').fadeOut();
                }
            }
        </script>         

    </h:body>
</html>

